New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add value_counts. #63
Conversation
cc @thunterdb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ueshin just a small question that can be solved by a comment. Feel free to merge the pull request after adding that comment. Great work!
databricks/koala/structures.py
Outdated
raise NotImplementedError("value_counts currently does not support bins") | ||
|
||
if dropna: | ||
df_dropna = self.to_dataframe().filter(self._spark_isNotNull()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this enough to filter not only the null but also the NaNs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but I am also marking this as something to cover in the guide in #34 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thunterdb updated to check the NaNs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ueshin a small refacting comment. This method is going to be very useful!
databricks/koala/structures.py
Outdated
|
||
if dropna: | ||
if isinstance(self.schema[self.name].dataType, (FloatType, DoubleType)): | ||
pred = ~(self._spark_isNull() | F._spark_isnan(self)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just implemented Series.isnull(). This is fine, we can refactor this piece later. I made an issue to do that later.
databricks/koala/structures.py
Outdated
@@ -534,10 +560,14 @@ def dropna(self, axis=0, how='any', thresh=None, subset=None, inplace=False): | |||
else: | |||
columns = list(self.columns) | |||
|
|||
def pred(c): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are repeating this logic twice already, would you mind going the whole way and defining PandasLikeSeries.inull
? We can add the tests later when fully implementing #64
|
||
isnull = isna | ||
|
||
def notna(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a doc here when working on #64.
@@ -260,6 +260,17 @@ def to_dataframe(self): | |||
def toPandas(self): | |||
return _col(self.to_dataframe().toPandas()) | |||
|
|||
def isna(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ueshin this is much cleaner now, thanks. Merging
No description provided.